package com.bes.aiProject.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bes.aiProject.entry.SxMBusinessProcessScore;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface SxMBusinessProcessScoreMapper extends BaseMapper<SxMBusinessProcessScore> {

    @Select("select  * from sx_m_business_process_score  \n" +
            "where metric_time<= #{maxTime}\t\n" +
            "<if test=“areaCode != null and areaCode != ‘’”>\n" +
            "and area_code = #{areaCode}\n" +
            "</if> \n" +
            "<if test=“customerType != null and customerType != ‘’”>\n" +
            "and customer_type = #{customerType}\n" +
            "</if> \n" +
            "<if test=“enterpriseCode != null and enterpriseCode != ‘’”>\n" +
            "and enterprise_code = #{enterpriseCode}\n" +
            "</if> \n" +
            "<if test=“businessCode != null and businessCode != ‘’”>\n" +
            "and business_code = #{businessCode}\n" +
            "</if> \n" +
            "<if test=“taskCode != null and taskCode != ‘’”>\n" +
            "and task_code = #{taskCode}\n" +
            "</if> ")
    List<SxMBusinessProcessScore> getTargetScore(@Param("areaCode") String areaCode, @Param("customerType") String customerType, @Param("enterpriseCode") String enterpriseCode, @Param("businessCode") String businessCode, @Param("taskCode") String taskCode, @Param("maxTime") LocalDateTime maxTime);
}
